<template>
	<view class="container">
		<TopNav title="营业执照"></TopNav>
		<view class="bg-white radius p-lr16 p-t13 p-b12 m-t10">
			<view class="">
				<text class="f-w600 f-s15 line-height22">我的营业执照</text>
			</view>
			<!-- <view class="m-t8">
				<text class="f-s12 f-w400 text-gray line-height17">最多上传3张图片，总大小不超过50M</text>
			</view> -->
			<view class="m-t10 full-width">
				<UploadImage width="100%" height="270rpx" v-model="form.certificates">
					<view class="upload-image">
						<image src="/static/images/login/photo.png" class="width-28" mode="widthFix"></image>
						<text class="m-t8 text-gray f-s12">上传图片</text>
					</view>
				</UploadImage>
			</view>
		</view>
		<view class="fixed-bottom bg-white p-lr16">
			<view class="self-btn full-width m-t6" hover-class="pressed" @click="handleSubmit">
				<text>设置</text>
			</view>
		</view>
		<Toast></Toast>
	</view>
</template>

<script>
	import UploadImage from '@/components/upload-image/index.vue'
	import {
		businessLicense
	} from '@/api/mine/setting.js'
	import { getInfo } from '@/api/login';
	export default {
		components: {
			UploadImage
		},
		data() {
			return {
				form: {
					certificates: ''
				}
			};
		},
		onLoad() {
			this.getDetail()
		},
		methods: {
			getDetail(){
				getInfo().then(res => {
					let {data:{technician_license}} = res
					this.form.certificates = technician_license?.certificates ?? ''
				})
			},
			handleSubmit() {
				if (!this.form.certificates) {
					this.$toast("请上传营业执照")
					return
				}
				this.$modal.loading('上传中').then(() => {
					businessLicense(this.form).then(res => {
						this.$toast(res.msg)
						this.$modal.closeLoading()
					}).catch(() => this.$modal.closeLoading())
				})

			}
		}
	}
</script>

<style scoped lang="scss">
	@import '@/common/css/var.scss';

	page {
		@include fixed-bottom;
	}

	.container {
		padding: 20rpx 24rpx;

		::v-deep .u-upload__wrap {
			display: block;
		}
	}
</style>